fix(cli): force-exit safety net for all commands, not just init - #1396
Open
jared-outpost[bot] wants to merge 1 commit into
Open
fix(cli): force-exit safety net for all commands, not just init#1396jared-outpost[bot] wants to merge 1 commit into
jared-outpost[bot] wants to merge 1 commit into
Conversation
Ordinary commands (org list, project list, auth status, etc.) finished their work and wrote complete output but the process never exited — lingering keep-alive sockets / a libuv refcount quirk on macOS+Bun kept the event loop referenced. The existing force-exit safety net was armed only for the init wizard. Generalize the helper (lib/init/force-exit.ts -> lib/force-exit.ts) and schedule it unconditionally in runCli's finally, after all recovery middleware has reached a terminal result. The unref'd timer only fires when a handle keeps the loop alive past a drained command, so it stays a no-op on clean exits and never arms commands whose awaited work never resolves. Fixes #1237
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
|
CI green (Build success). Self-review clean. Promoted to ready-for-review. Added issue author @azataiot as reviewer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ordinary commands (
org list,project list,issue view,auth status, etc.) finish their work and write complete output, but the process never exits — a lingering handle (keep-alive sockets / a libuv refcount quirk on macOS + Bun) keeps the event loop referenced. This is the same class of hang as #782/#833, but for everyday commands rather than the init wizard.Fix
The force-exit safety net already existed but was armed only for
initvia a request flag. This generalizes it:src/lib/init/force-exit.ts→src/lib/force-exit.ts, collapsing the request/schedule pair into a singlescheduleForceExit().runCli'sfinallynow callsscheduleForceExit()unconditionally, after all recovery middleware (auto-auth, scope recovery, retry) has reached a terminal result.requestInitForceExit()call.The timer is scheduled only after the awaited command resolves, and
.unref()means it fires only when another handle keeps the loop alive past a drained command. So it stays a no-op on clean exits and never arms commands that intentionally keep running (their awaited work never resolves, so thefinallyis never reached). Guarded to macOS andNODE_ENV !== "test".Tests
test/lib/force-exit.test.tsfor the simplified API (schedules unref'd 100ms timer on macOS outside tests; no-op elsewhere / in tests).test/commands/init.test.tsto drop the removed request-flag spy.vitest run test/lib/force-exit.test.ts test/commands/init.test.ts→ 48 passed.Closes #1237